﻿Imports extranet.BE
Imports extranet.DA

Public Class BCVideo

  Public Shared Sub Cadastrar(ByRef objBEVideo As BEVideo)
    Dim objDAVideo As New DAVideo
    objDAVideo.Cadastra(objBEVideo)
  End Sub

  Public Shared Sub Atualizar(ByVal objBEVideo As BEVideo)
    Dim objDAVideo As New DAVideo
    objDAVideo.Atualiza(objBEVideo)
  End Sub

  Public Shared Sub AtualizarImagem(ByVal objBEVideo As BEVideo)
    Dim objDAVideo As New DAVideo
    objDAVideo.AtualizaImagem(objBEVideo)
  End Sub

  Public Shared Sub Excluir(ByVal objBEVideo As BEVideo)
    Dim objDAVideo As New DAVideo
    objDAVideo.Exclui(objBEVideo)
  End Sub

  Public Shared Function Selecionar(ByVal intIdVideo As Integer) As List(Of BEVideo)
    Dim objDAVideo As New DAVideo
    Dim objBEVideo As New BEVideo
    objBEVideo.IdVideo = intIdVideo
    Return objDAVideo.SelecionaVideos(objBEVideo)
  End Function

  Public Shared Function SelecionarUltimoVideo() As BEVideo
    Dim objDAVideo As New DAVideo
    Return objDAVideo.SelecionaUltimoVideo()
  End Function

  Public Shared Function Selecionar(ByVal strTituloDescricao As String, ByVal strCategoria As String, _
                                    ByVal strUsuario As String, _
                                    ByVal sortExpression As Object, ByVal sortDirection As Object) As List(Of BEVideo)
    Dim objDAVideo As New DAVideo
    Dim objBEVideo As New BEVideo
    objBEVideo.Titulo = strTituloDescricao
    objBEVideo.Descricao = strTituloDescricao
    objBEVideo.Categoria = New BECategoriaVideo(0, strCategoria)
    objBEVideo.Usuario = New BEUsuario(strUsuario, "")
    If TypeOf (sortExpression) Is Array Then
      Dim arrExpression() As String = sortExpression
      Dim arrDirection() As String = sortDirection
      For intI As Integer = 0 To arrExpression.Length - 1
        objDAVideo.objQuery.Sort.AdicionarCondicaoOrderBy(arrExpression(intI), arrDirection(intI))
      Next
    Else
      objDAVideo.objQuery.Sort = New BESort(sortExpression, sortDirection)
    End If
    Return objDAVideo.SelecionaVideos(objBEVideo)
  End Function

  Public Shared Function Ranking(ByVal idVideo As Integer) As Boolean
    If idVideo <= 0 Then Return False
    Dim objDAVideo As New DAVideo
    Return objDAVideo.Ranking(New BEVideo(idVideo))
  End Function

End Class
